Show example
|
- By default are row's children calculated before row's cells.
You can change this direction by adding '*' to CalcOrder to position, where you want to calculate children.
- For more complex calculation order you can divide CalcOrder attributes to more parts (CalcOrder,CalcOrder1,CalcOrder2,...)
and reference these orders from parent row's CalcOrder by *,*1,*2,...
- In this example is used this calculation order:
- First are calculated columns Total and Tmp upstairs (child rows before parent).
The tmp column is used only as temporary and should be hidden by setting Visible='0' and CanHide='0'.
- Next are calculated columns PerParent and PerTotal downstairs (parent before child rows).
Because formulas in these columns use calculated result from fixed Root row.
- Because of complex calculation order, the Recalc attribute of all rows is set to 256 to recalculate the whole grid after any change.
- If you have more fixed rows and you want to calculate their cells by random, you can use <Cfg> attribute CalcOrder instead of CalcOrder of fixed rows.
|
Show data source
<Grid>
<Cfg id='Calc4' MainCol='Node'/>
<Cols>
<C Name='Node' Type='Text'/>
<C Name='Active' Type='Bool'/>
<C Name='Cost' Type='Float'/>
<C Name='Total' Type='Float'/>
<C Name='Quantity' Type='Int'/>
<C Name='Tmp' Type='Float'/>
<C Name='PerParent' Type='Int'
Format='0%'/>
<C Name='PerTotal' Type='Int'
Format='0%'/>
</Cols>
<Header Wrap='1' Cost='Local cost'
Total='Total cost'
Quantity='Total quantity'
Tmp='Tmp cost (hidden)'
PerParent='% of parent cost'
PerTotal='% of total cost'/>
<Def>
<D Name='R' Calculated='1' Recalc='256'
TotalFormula='Cost+sum("Tmp")'
TmpFormula='Active*Total*Quantity'
CalcOrder='*,Total,Tmp'
CalcOrder1='PerParent,PerTotal,*1'
PerParentFormula='Tmp/Parent.Total'
PerTotalFormula='PerParent*Parent.PerTotal'
/>
<D Name='FirstLevel'
PerParentFormula='Tmp/Root.Total'
PerTotalFormula='PerParent'
/>
</Def>
<Body>
<B>
<I Def='FirstLevel' Node='Level 1'
Active='1' Cost='125' Quantity='4'>
<I Node='Level 1-1' Active='1'
Cost='25' Quantity='3'/>
<I Node='Level 1-2' Active='1'
Cost='4' Quantity='4'>
<I Node='Level 1-2-1' Active='0'
Cost='20' Quantity='8'/>
<I Node='Level 1-2-2' Active='1'
Cost='5' Quantity='2'/>
</I>
<I Node='Level 1-3' Active='0'
Cost='122' Quantity='12'/>
</I>
<I Def='FirstLevel' Node='Level 2'
Active='1' Cost='21' Quantity='3'>
<I Node='Level 2-1' Active='1'
Cost='28' Quantity='4'/>
</I>
</B>
</Body>
<Foot>
<I id='Root' CalcOrder='*,Total,Tmp,*1'
Node='Root' CanEdit='0'
ActiveType='Text' CostType='Text'
QuantityType='Text' TmpFormula=' '
TmpType='Text'
TotalFormula='sum("Tmp")'
PerParentType='Text' PerTotal='1'/>
</Foot>
</Grid>
|